/*
 * DocumentImpl.h
 *
 *  Created on: Apr 19, 2009
 *      Author: wrice
 */

#ifndef DOCUMENTIMPL_H_
#define DOCUMENTIMPL_H_
#include "DOMCoreImp.h"
namespace DOMCoreImp {


class DocumentImp : public NodeImp, IMPLEMENTS( Document ), IMPLEMENTS( DocumentView ), IMPLEMENTS( DocumentTraversal ) {
protected:
	DocumentImp();

public: // from NodeImp, Document
	virtual unsigned short getNodeType();

	virtual Element * getDocumentElement();
	virtual NodeList * getElementsByTagName(DOMString tagname);

	virtual Element * createElement(DOMString tagName) throw(DOMExceptionPtr);
	virtual Attr * createAttribute(DOMString name) throw(DOMExceptionPtr);
	virtual Text * createTextNode(DOMString data);

	// blocking nodeValue
	virtual DOMString getNodeValue() throw(DOMExceptionPtr);
	virtual void setNodeValue(DOMString) throw(DOMExceptionPtr);

	// blocking child
	virtual Node * insertBefore( Node * newChild, Node * refChild ) throw(DOMExceptionPtr);
	virtual Node * replaceChild( Node * newChild, Node * oldChild ) throw (DOMExceptionPtr);
	virtual Node * appendChild( Node * newChild) throw(DOMExceptionPtr);

public: // from DocumentView
	virtual AbstractView * getDefaultView();

public: // from DocumentTraversal
	virtual NodeIterator * createNodeIterator(
							Node * root,
							unsigned long whatToShow,
							NodeFilter * filter,
							bool entityReferenceExpansion) throw(DOMExceptionPtr);

	virtual TreeWalker * createTreeWalker(
							Node * root,
							unsigned long whatToShow,
							NodeFilter * filter,
							bool entityReferenceExpansion) throw(DOMExceptionPtr);

public: // new methods
	virtual ElementImp * createElementImp( DOMString tagName ) throw(DOMExceptionPtr);
	virtual AttrImp * createAttributeImp( DOMString name ) throw(DOMExceptionPtr);
	virtual TextImp * createTextNodeImp(DOMString data);
	virtual void setDefaultView(AbstractView * view);

private:
	typedef list< ElementImpPtr > ElementImps;
	typedef list< AttrImpPtr > AttrImps;
	typedef list< TextImpPtr > TextImps;
	typedef list< NodeIteratorPtr > NodeIterators;
	typedef list< TreeWalkerPtr > TreeWalkers;

	ElementImps elementImps_;
	AttrImps attrImps_;
	TextImps textImps_;
	NodeIterators nodeIterators_;
	TreeWalkers treeWalkers_;

	struct Imp;
};


}

#endif /* DOCUMENTIMPL_H_ */
